package com.xjscrm.console.web.xxljob;
import com.xjscrm.console.service.common.xxljob.XxlJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "XxlJob调用", tags = "XxlJob调用")
@RestController
@RequestMapping(value = "/xxlJob")
public class XxlJobController {

    @Autowired
    private XxlJobService xxlJobService;

    @ApiOperation(value = "清理每日已接受邀请数 (每天凌晨执行一次)", notes = "清理每日已接受邀请数 (每天凌晨执行一次)",response = Boolean.class)
    @PostMapping(value ="/wwGroup/invite/clearAcceptToday" )
    public Object clearAcceptToday()throws Exception{
        xxlJobService.clearAcceptToday();
        return true;
    }


    @ApiOperation(value = "执行群邀请任务 (每30s执行一次)", notes = "执行群邀请任务 (每30s执行一次)", response = Boolean.class)
    @PostMapping(value ="/wwGroup/invite/excuteTask" )
    public Object excuteTask()throws Exception{
        xxlJobService.excuteTask();
        return true;
    }

    @ApiOperation(value = "执行同步通讯录任务 (每2min执行一次)", notes = "执行同步通讯录任务 (每2min执行一次)", response = Boolean.class)
    @PostMapping(value = "/wwCustomer/syncCustomer")
    public Object syncCustomer() throws Exception {
        xxlJobService.syncCustomer();
        return true;
    }


    @ApiOperation(value = "执行同步客户群任务 (每2min执行一次)", notes = "执行同步客户群任务 (每2min执行一次)", response = Boolean.class)
    @PostMapping(value = "/wwGroup/syncGroup")
    public Object syncGroup() throws Exception {
        xxlJobService.syncGroup();
        return true;
    }


    @ApiOperation(value = "执行同步个人标签任务 (每2min执行一次)", notes = "执行同步个人标签任务 (每2min执行一次)", response = Boolean.class)
    @PostMapping(value = "/wwCustomer/syncPersonTag")
    public Object syncPersonTag() throws Exception {
        xxlJobService.syncPersonTag();
        return true;
    }

    @ApiOperation(value = "处理立即或者定时发送的极速群发任务 (每5s执行一次)", notes = "处理立即或者定时发送的极速群发任务 (每5s执行一次)", response = Boolean.class)
    @PostMapping(value = "/speedGroupSendJob/Immediately")
    public Object autoGroupSendTaskSyncByImmediately() throws Exception {
        xxlJobService.autoGroupSendTaskSyncByImmediately();
        return true;
    }

    @ApiOperation(value = "处理循环的极速群发任务 (每30s执行一次)", notes = "处理循环的极速群发任务 (每30s执行一次)", response = Boolean.class)
    @PostMapping(value = "/speedGroupSendJob/Cycle")
    public Object autoGroupSendTaskSyncByCycle() throws Exception {
        xxlJobService.autoGroupSendTaskSyncByCycle();
        return true;
    }


    @ApiOperation(value = "处理极速群发的job (每30s执行一次)", notes = "处理极速群发的job(每30s执行一次)", response = Boolean.class)
    @PostMapping(value = "/speedGroupSendJob/executeJob")
    public Object autoGroupSendJob() throws Exception {
        xxlJobService.autoGroupSendJob();
        return true;
    }


    @ApiOperation(value = "执行朋友圈任务 (每分钟执行一次)", notes = "执行朋友圈任务 (每分钟执行一次)", response = Boolean.class)
    @PostMapping(value = "/circleTask/execute")
    public Object executeCircleTask() throws Exception {
        xxlJobService.executeCircleTask();
        return true;
    }

    @ApiOperation(value = "执行清理聊天记录 (每天执行一次)", notes = "执行清理聊天记录 (每天执行一次)", response = Boolean.class)
    @PostMapping(value = "/cleanChatTalkRecord/execute")
    public Object cleanChatTalkRecord() throws Exception {
        xxlJobService.executeCleanChatTalkRecord();
        return true;
    }
}
